package cn.dansj.service.Impl;

import cn.dansj.entity.ArticleTag;
import cn.dansj.repository.ArticleTagRepository;
import cn.dansj.service.ArticleTagService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ArticleTagServiceImpl implements ArticleTagService {
    private final ArticleTagRepository articleTagRepository;

    public ArticleTagServiceImpl(ArticleTagRepository articleTagRepository) {
        this.articleTagRepository = articleTagRepository;
    }

    @Override
    @Transactional
    public void deleteByBlogSequence(String blogSequence) {
        articleTagRepository.deleteAllByBlogSequence(blogSequence);
    }

    @Override
    public int save(List<ArticleTag> articleTags) {
        return articleTagRepository.saveAll(articleTags).size();
    }

    @Override
    public List<Object[]> tagCount() {
        return articleTagRepository.tagCount();
    }
}
